package com.max.baselib.widget.toolbar

import androidx.annotation.ColorInt
import androidx.annotation.StyleRes
import com.max.baselib.widget.toolbar.ToolbarConstants.Companion.def_back_navigationResId
import com.max.baselib.widget.toolbar.ToolbarConstants.Companion.def_bgColor_NaN
import com.max.baselib.widget.toolbar.ToolbarConstants.Companion.def_titleStyle_NaN

/**
 *  Created by ：2020/7/27
 *  author : Administrator
 *  Toolbar配置类
 */
class ToolbarConfig private constructor(){

    /**
     * 标题文字样式
     */
    @StyleRes var titleStyle : Int = def_titleStyle_NaN

    /**
     * toolbar 背景色
     */
    @ColorInt var bgColor : Int = def_bgColor_NaN

    /**
     * 左侧图标
     */
    var navigationIcon:Int = def_back_navigationResId

    /**
     *  toolbar样式 （Toolbar标题文字居左、Toolbar标题文字居中）
     */
    var toolbarType : ToolbarType = ToolbarType.CenterTitle

    companion object{

        /**
         * 默认配置
         */
        fun defaultConfig():ToolbarConfig{
            return ToolbarConfig()
        }

        /**
         * Toolbar标题文字居左的配置
         */
        fun createLeftTitleConfig(@ColorInt bgColor : Int = def_bgColor_NaN, @StyleRes titleStyle : Int = def_titleStyle_NaN, navigationIcon:Int = def_back_navigationResId):ToolbarConfig{
            return ToolbarConfig().also {
                it.bgColor = bgColor
                it.titleStyle = titleStyle
                it.navigationIcon = navigationIcon
                it.toolbarType = ToolbarType.LeftTitle
            }
        }

        /**
         * Toolbar标题文字居中的配置
         */
        fun createCenterTitleConfig(@ColorInt bgColor : Int = def_bgColor_NaN, @StyleRes titleStyle : Int = def_titleStyle_NaN, navigationIcon:Int = def_back_navigationResId):ToolbarConfig{
            return ToolbarConfig().also {
                it.bgColor = bgColor
                it.titleStyle = titleStyle
                it.navigationIcon = navigationIcon
                it.toolbarType = ToolbarType.CenterTitle
            }
        }
    }

}